package tutorial;

import java.util.Scanner;

public class TranslateDecimalToBinary {
	public static void main(String[] args) {
		System.out.print("Enter an integer: ");
		Scanner in = new Scanner(System.in);
		int d = in.nextInt();
		StringBuilder sb = new StringBuilder();

		int x = 1;
		for (int i = 0; i < 8; i++) {
			sb.append((d & x) == 0 ? "0" : "1");
			x <<= 1;
		}

		System.out.println("result = " + sb.reverse());
	}
}
